package com.qiwenshare.stock.controller;

import com.qiwenshare.stock.strategy.MacdStrategy;
import com.qiwenshare.stock.strategy.RangeBreakStrategy;
import com.qiwenshare.stock.strategy.WeekBreakStrategy;
import com.qiwenshare.stock.util.DataUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @ClassName Strategy
 * @Description TODO
 * @Author peng.zhang
 * @Date 9:10 2023/6/8
 * @Version 1.0
 **/
@RequestMapping("strategy")
@RestController
public class StrategyController {
    @Resource
    private RangeBreakStrategy rangeBreakStrategy;
    @Resource
    private WeekBreakStrategy weekBreakStrategy;
    @Resource
    private MacdStrategy macdStrategy;

    @GetMapping("rangeBreakCurrent")
    public Object rangeBreakCurrent() {
        return DataUtil.rangeBreak(false,new Date());
    }

    @GetMapping("rangeBreakHigh")
    public Object rangeBreakHigh() {
        return DataUtil.rangeBreak(true,new Date());
    }

    @GetMapping("rangeBreak/backTest")
    public Object backTest(String start,String end) {
        rangeBreakStrategy.backTest(start,end);
        return "ok";
    }

    @GetMapping("weekBreak/backTest")
    public Object weekBreakBackTest(String start,String end) {
        weekBreakStrategy.backTest(start,end);
        return "ok";
    }

    @GetMapping("macd/backTest")
    public Object macd(String start,String end) {
        macdStrategy.backTest(start,end);
        return "ok";
    }
}
